package com.dpiinc.TechPage.room;

import android.content.Context;

import com.dpiinc.TechPage.room.bean.PenEntity;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Created by hu489_000 on 2018-07-28.
 */

public class PenDaoUtils {
    @Nullable
    public static String getPenName(@NotNull Context context, String defaultName, String mac) {

        RoomAiWriterDatabase db = RoomAiWriterDatabase.getInstance(context);
        if(context== null || mac == null || db == null){
            return defaultName;
        }
        PenEntity mPenEntity = db.penDao().getPenByMacAddress(mac);
        if(mPenEntity == null){
            return defaultName;
        }
        return mPenEntity.getName();
    }
}
